# ------------------------------------------------------------------------------
#
# Copyright (c) 2011 - The OWE Team
#
# This file is part of OWE.
#
# OWE is a free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; version
# version 2.1 of the License.
#
# OWE is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with OWE. If not, see <http://www.gnu.org/licenses/>.
#
# ------------------------------------------------------------------------------

project("OWE")

cmake_minimum_required(VERSION 2.6)

# ------------------------------------------------------------------------------
# Project configurable options
# ------------------------------------------------------------------------------
option(ENABLE_QT            "Enable Qt bindings and backend."               ON)
option(ENABLE_GTK           "Enable GTK+ bindings and backend."             OFF)

option(ENABLE_EXAMPLES      "Build API usage code samples."                 ON)
option(ENABLE_DOCUMENTATION "Generate documentation if Doxygen is present." ON)
option(ENABLE_AUTOTESTS     "Enable auto tests infrastructure."             ON)

# ------------------------------------------------------------------------------
# Global settings
# ------------------------------------------------------------------------------

set(CMAKE_BUILD_TYPE Debug CACHE STRING "Default build mode." FORCE)

set(OWE_CONFIGURATION_DIR ${CMAKE_SOURCE_DIR}/src/configuration)
set(OWE_INTERFACES_DIR    ${CMAKE_SOURCE_DIR}/src/interfaces)
set(OWE_PACKAGING_DIR     ${CMAKE_SOURCE_DIR}/src/packaging)
set(OWE_UTILS_DIR         ${CMAKE_SOURCE_DIR}/src/utils)

include_directories(${CMAKE_BINARY_DIR}/include)

if(CMAKE_COMPILER_IS_GNUCXX)
    set(CMAKE_CXX_FLAGS
        "${CMAKE_CXX_FLAGS} -W -Wall -Wextra"
    )
endif()

if(CMAKE_HOST_WIN32)
    set(CMAKE_CXX_FLAGS
        "${CMAKE_CXX_FLAGS} -DOWE_OS_WIN"
    )
endif()

# ------------------------------------------------------------------------------
# Documentation
# ------------------------------------------------------------------------------
if(ENABLE_DOCUMENTATION)
    set(DOXYFILE_LATEX "NO")
    set(DOXYFILE_SOURCE_DIR "${OWE_CONFIGURATION_DIR} ${OWE_PACKAGING_DIR} ${OWE_UTILS_DIR}")
    include(${CMAKE_SOURCE_DIR}/scripts/doxygen.cmake OPTIONAL)
endif()

# ------------------------------------------------------------------------------
# Folders to build
# ------------------------------------------------------------------------------
if(ENABLE_AUTOTESTS)
    enable_testing()
    add_subdirectory(${CMAKE_SOURCE_DIR}/tests)
    include(${CMAKE_SOURCE_DIR}/scripts/lcov.cmake OPTIONAL)
endif()

if(ENABLE_EXAMPLES)
    add_subdirectory(${CMAKE_SOURCE_DIR}/examples)
endif()

add_subdirectory(${CMAKE_SOURCE_DIR}/src)
